package io.gitee.twoke.generator.engine.impl.generate.impl;

import io.gitee.twoke.generator.engine.impl.AbstractQuery;
import io.gitee.twoke.generator.engine.impl.Page;
import io.gitee.twoke.generator.engine.impl.generate.DataTableColumn;
import io.gitee.twoke.generator.engine.impl.generate.DataTableColumnQuery;
import io.gitee.twoke.generator.engine.impl.interceptor.CommandContext;
import io.gitee.twoke.generator.engine.impl.interceptor.CommandExecutor;
import lombok.Getter;
import lombok.Setter;

import java.util.List;

@Getter
@Setter
public class DataTableColumnQueryImpl
   extends AbstractQuery<DataTableColumnQuery, DataTableColumn>
        implements DataTableColumnQuery{
    private String id;
    private String tableId;

    public DataTableColumnQueryImpl(CommandExecutor commandExecutor, String databaseType) {
        super(commandExecutor);
        this.databaseType = databaseType;
    }

    @Override
    public long executeCount(CommandContext commandContext) {
        return commandContext.getDataTableColumnEntityManager().findDataTableColumnCountByQueryCriteria(this);
    }

    @Override
    public List<DataTableColumn> executeList(CommandContext commandContext, Page page) {
        return commandContext.getDataTableColumnEntityManager().findDataTableColumnsByQueryCriteria(this);
    }

    @Override
    public DataTableColumnQuery id(String columnId) {
        this.id = columnId;
        return this;
    }

    @Override
    public DataTableColumnQuery tableId(String tableId) {
        this.tableId = tableId;
        return this;
    }
}
